#include "proto.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/msg.h>

int main()
{
    key_t key;
    int msgid;
    struct msg_st sbuf;

    key = ftok(KEYPATH, KEYPROJ);
    if(key < 0)
    {
        perror("ftok");
        exit(1);
    }
    msgid = msgget(key, 0);
    if(msgid < 0)
    {
        perror("msgget");
        exit(1);
    }
    sbuf.mtype = 1;
    strcpy(sbuf.name, "aa");
    sbuf.math = 1;
    sbuf.chinese = 2;
    if(msgsnd(msgid, &sbuf, sizeof(sbuf) - sizeof(long), 0) < 0)
    {
        perror("msgsnd");
        exit(1);
    }
    puts("ok");

    exit(0);
}